//
//  UIAlertController+KFD.m
//  KFD
//
//  Created by JIRENTIANXIANG on 7/9/15.
//  Copyright © 2015 kfd. All rights reserved.
//

#import "UIAlertController+KFD.h"
#import "KFDLoginViewController.h"
#import "KFDRegisterViewController.h"

@implementation UIAlertController (KFD)

+(UIAlertController*)presentLoginRegisterAlertControllerWithMessage:(NSString *)message byViewController:(UIViewController *)viewController
{
    UIAlertController* alertController=[UIAlertController alertControllerWithTitle:nil message:message preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction* loginAction=[UIAlertAction actionWithTitle:@"登录" style:UIAlertActionStyleDefault handler:^(UIAlertAction * __nonnull action) {
        KFDLoginViewController* loginVC=[[UIStoryboard storyboardWithName:@"KFDLogin" bundle:nil] instantiateViewControllerWithIdentifier:@"KFDLoginViewController"];
        loginVC.sourceViewController=viewController;
        [viewController.navigationController pushViewController:loginVC animated:YES];
    }];
    [alertController addAction:loginAction];
    UIAlertAction* registerAction=[UIAlertAction actionWithTitle:@"注册" style:UIAlertActionStyleDefault handler:^(UIAlertAction * __nonnull action) {
        KFDRegisterViewController* registerVC=[[UIStoryboard storyboardWithName:@"KFDRegister" bundle:nil] instantiateViewControllerWithIdentifier:@"KFDRegisterViewController"];
        registerVC.sourceViewController=viewController;
        [viewController.navigationController pushViewController:registerVC animated:YES];
    }];
    [alertController addAction:registerAction];
    [viewController presentViewController:alertController animated:YES completion:nil];
    return alertController;
}

@end
